package com.yanqu.road.server.manger.activity.dafuweng.event;

import com.yanqu.road.entity.activity.dafuweng.DFWEvent;
import com.yanqu.road.entity.activity.dafuweng.DFWUserData;
import com.yanqu.road.entity.enums.activity.dafuweng.eDaFuWengEventType;
import com.yanqu.road.server.manger.activity.dafuweng.DaFuWengMgr;
import com.yanqu.road.server.manger.activity.dafuweng.building.BaseDFWBuilding;
import com.yanqu.road.utils.property.Property;

/**
 * @Author wpj
 * @Date 2021/1/7
 */
public abstract class BaseDFWEvent {

    DFWEvent dfwEvent;

    BaseDFWBuilding baseDFWBuilding;

    DFWUserData userData;
    boolean unionCollectReachReward = false;

    boolean isCanDoCollectEvent = true;

    String reward = "";

    // 其利断金升级时设置对应ID
    int newBattleSkillId = 0;
    // 宝箱事件：触发收集奖励时记录道具
    Property boxCollectReward = new Property();

    public BaseDFWEvent(BaseDFWBuilding baseDFWBuilding, DFWEvent dfwEvent) {
        this.dfwEvent = dfwEvent;
        this.baseDFWBuilding = baseDFWBuilding;
        getUserData();
    }

    public void getUserData() {
        userData = DaFuWengMgr.getUserData(baseDFWBuilding.getDfwConfig().getActivityInfo().getActivityId(), baseDFWBuilding.getPlayer().getUserId());
    }

    /**
     * 执行事件的逻辑
     */
    public abstract void doEvent();

    public static BaseDFWEvent getBaseEvent(BaseDFWBuilding baseDFWBuilding, DFWEvent dfwEvent) {
        if (dfwEvent.getEventType() == eDaFuWengEventType.Normal) {
            return new DFWNormalEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.ZaoYao) {
            return new DFWZaoYaoEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.StartReward) {
            return new DFWStartRewardEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.CollectGoods) {
            return new DFWCollectGoodsEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.RecoverPower) {
            return new DFWRecoverPowerEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Secret) {
            return new DFWSecretEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Empty) {
            return new DFWEmptyEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Trade) {
            return new DFWTradeEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Package) {
            return new DFWPackageEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Boss) {
            return new DFWBossEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Box) {
            return new DFWBoxEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Vehicle) {
            return new DFWVehicleEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.God) {
            return new DFWGodEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Cal) {
            return new DFWCalEvent(baseDFWBuilding, dfwEvent);
        } else if (dfwEvent.getEventType() == eDaFuWengEventType.Blacksmith) {
            return new DFWBlacksmithEvent(baseDFWBuilding, dfwEvent);
        }
        return null;
    }

    public DFWEvent getDfwEvent() {
        return dfwEvent;
    }

    public boolean isUnionCollectReachReward() {
        return unionCollectReachReward;
    }

    public boolean isCanDoCollectEvent() {
        return isCanDoCollectEvent;
    }

    public String getReward() {
        return reward;
    }

    public int getNewBattleSkillId() {
        return newBattleSkillId;
    }

    public void setNewBattleSkillId(int newBattleSkillId) {
        this.newBattleSkillId = newBattleSkillId;
    }

    public Property getBoxCollectReward() {
        return boxCollectReward;
    }

    public void setBoxCollectReward(Property boxCollectReward) {
        this.boxCollectReward = boxCollectReward;
    }
}
